package com.bmslz.monitor.base.dto;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bmslz.monitor.base.util.StringUtils;
import com.bmslz.monitor.base.entity.AlarmModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @Description: 告警模板查询入参
 * @Author: bobo
 * @Date: 2025-08-10
 * @Version: V1.0
 */
@Data
public class AlarmModelSearchDto {

    @ApiModelProperty(value = "模板名称")
    private String name;
    @ApiModelProperty(value = "监控模型id")
    private String monitorModelId;

    public LambdaQueryWrapper<AlarmModel> wrapper() {
        LambdaQueryWrapper<AlarmModel> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(StringUtils.isNotEmpty(monitorModelId), AlarmModel::getMonitorModelId, monitorModelId);
        if (StringUtils.isNotEmpty(name)) {
            wrapper
                    .and(w -> w.like(AlarmModel::getName, name)
                            .or()
                            .like(AlarmModel::getModelNo, name));
        }
        wrapper.orderByDesc(AlarmModel::getCreateTime);
        return wrapper;
    }
}
